<?php

namespace hotel\common\utils;

use shop\common\models\App;
use Yii;

class AcServices {


    //积分
    public static function addIntegral($appid,$member_id,$orderid,$integral,$remark,$way){
        $url =  \Yii::$app->params['ac_url'] . "member/integral/add-integral";
        $data = [];
        $data['app'] = 'shop';
        $data['appid'] = $appid;
        $data['member_id'] = $member_id;
        $data['flag'] = 2;
        $data['content_id'] = $orderid;
        $data['integral'] = $integral;
        $data['remark'] = $remark;
        $data['way'] = $way;
        $data['secretkey'] = 'j5pAPD7dXFPfhky9ASTfBuKomcTK8qzN';
        $result = \hotel\common\utils\HttpClient::post($url, $data);
        $res = json_decode($result, true);
        return $res;
    }

    //核销优惠券
    public static function useCoupon($appid,$member_id,$couponid){
        $url =  \Yii::$app->params['ac_url'] . "member/coupon/use-coupon";
        $data = [];
        $data['appid'] = $appid;
        $data['member_id'] = $member_id;
        $data['code'] = $couponid;
        $data['useremark'] = '酒店核销优惠券';
        $data['secretkey'] = 'j5pAPD7dXFPfhky9ASTfBuKomcTK8qzN';
        $result = \hotel\common\utils\HttpClient::post($url, $data);
        $res = json_decode($result, true);
        if($res['code'] == 0){
            return true;
        }
        return false;
    }

}